using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Services;

namespace Sudoku.Menu
{
	public class Achievements : ExtendedGameComponent
	{
		Texture2D bg;
		Rectangle bgPos;
		Color bgColor;

		SpriteFont headerFont;
		Color headerColor;
		String header;
		Vector2 headerPos;

		IInputManager inputService;

		public Achievements(Game game)
			: base(game)
		{

		}

		public override void Initialize()
		{
			inputService = Game.Services.GetService(typeof(IInputManager)) as IInputManager;
			inputService.OnTap += new InputManager.TouchEvent(OnTap);
			inputService.OnBack += new InputManager.PhoneButtonEvent(Back);

			bg = textureService.Background("General");
			bgPos = new Rectangle(0, 0, 480, 800);
			bgColor = Color.White;

			//HEADER
			headerFont = fontService.Font(FontType.Delicious48);
			header = "Achievements";
			headerColor = new Color(0, 102, 153);
			headerPos = new Vector2(240 - (headerFont.MeasureString(header).X * 0.5f), 20);

		}

		protected override void Dispose(bool disposing)
		{
			inputService.OnTap -= new InputManager.TouchEvent(OnTap);
			inputService.OnBack -= new InputManager.PhoneButtonEvent(Back);

			base.Dispose(disposing);
		}

		private void Back()
		{
			soundService.PlaySound(SoundType.Fumble);
			StateManagement.StateManager.StartMenu(Game);
		}

		private void OnTap(Vector2 pos)
		{
			StateManagement.StateManager.StartMenu(Game);
			soundService.TurnPageSound();
		}

		public override void Draw(GameTime gameTime)
		{

			spriteBatch.Begin();

			spriteBatch.Draw(bg, bgPos, bgColor);

			spriteBatch.End();

			base.Draw(gameTime);
		}

	}
}
